{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python输出颜色方式控制"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 语法\n",
    "`\"\\033[显示方式;前景色;背景色m\"`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 后续输出配置\n",
    "在结尾设置\n",
    "- 恢复默认：`\"\\033[0m\"`\n",
    "- 其他配置：`\"\\033[4;30;43m\"`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 颜色\n",
    "\n",
    "|前景色|背景色|颜色\n",
    "|:--|:--|:--\n",
    "|30|40|黑色\n",
    "|31|41|红色\n",
    "|32|42|绿色\n",
    "|33 \t|43 \t|黃色\n",
    "|34 \t|44 \t|蓝色\n",
    "|35 \t|45 \t|紫红色\n",
    "|36 \t|46 \t|青蓝色\n",
    "|37 \t|47 \t|白色"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 显示方式\n",
    "|显示方式 \t|意义\n",
    "|:--|:--\n",
    "|0 \t|终端默认设置\n",
    "|1 \t|高亮显示\n",
    "|4 \t|使用下划线\n",
    "|5 \t|闪烁\n",
    "|7 \t|反白显示\n",
    "|8 \t|不可见"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[93mThere is a mistake in the backward propagation! difference = \u001b[0m\n",
      "hello\n"
     ]
    }
   ],
   "source": [
    "print (\"\\033[93m\" + \"There is a mistake in the backward propagation! difference = \" +\"\\033[0m\" )\n",
    "print(\"hello\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[93mThere is a mistake in the backward propagation! difference = \u001b[4;30;43m\n",
      "hello\n"
     ]
    }
   ],
   "source": [
    "print (\"\\033[93m\" + \"There is a mistake in the backward propagation! difference = \" +\"\\033[4;30;43m\" )\n",
    "print(\"hello\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 参考资料\n",
    "1.[Python实现设置终端显示颜色、粗体、下划线等效果](https://blog.csdn.net/gatieme/article/details/45439671)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
